--[[
通用任务操作相关
]]

--[[
某些任务接取后进入副本
刷怪、面板处理
]]
function OnCommonQuestFubenEnter( sysarg, fubenId )
	local Hfuben = Fuben.createFuBen( fubenId )          --1:表示副本ID
	if Hfuben <= 0 then
		return
	end
	--print("OnCommonQuestFubenEnter="..fubenId)
	if Actor.enterFuBen(sysarg, Hfuben,-1,-1,-1) then
		if FuBen[fubenId].questMonsters then				 --任务拉传，需要立即刷出怪
			if FuBen[fubenId].dir and 1 <= FuBen[fubenId].dir and FuBen[fubenId].dir <= 8 then
				Actor.setDir( sysarg, FuBen[fubenId].dir )
				--print("OnCommonQuestFubenEnter="..FuBen[fubenId].dir)
			end
			FreshCommonMonsters( FuBen[fubenId].questMonsters, Hfuben, true )

			local fubenCfg 		= {}
			local contStyle 	= FuBen[fubenId].contStyle					--内容风格， 3
			local buttons 		= {1}
			local activityId 	= enRightPanelActivity_QuestFuben
			local subActivityId = 0
			fubenCfg.monsters 	= FuBen[fubenId].questMonsters
			OpenCommonStylePanel( sysarg, 1, activityId, subActivityId, FuBen[fubenId].fbname, fubenCfg, contStyle, buttons  )

			if FuBen[fubenId].teleport and FuBen[fubenId].teleport.passVisible then
				local hScene = Actor.getSceneHandle(sysarg)
				System.setTeleportVisible( false, hScene, FuBen[fubenId].teleport.posx, FuBen[fubenId].teleport.posy )
			end
		end
	end
end


--[[
副本任务怪被击杀
面板处理
]]
function OnCommonQuestFubenMonsterKilled( monster, Killer, monId, lastHitKiller )
	local fubenId = Actor.getFubenId( monster )
	--print("OnCommonQuestFubenMonsterKilled, monId="..monId..", fubenId="..fubenId)
	local fubenCfg = {}
	fubenCfg.monsters = FuBen[fubenId].questMonsters
	local panelSts 	= nil
	local contStyle = FuBen[fubenId].contStyle					--内容风格， 3
	ChangeCommonStylePanel( Killer, panelSts, contStyle, fubenCfg, {1}, {1} )

	local fubenPtr 		= Actor.getFubenPrt(Killer)
	local fubenHandle	= Fuben.getFubenHandle(fubenPtr)
	local allBoss, killBoss, allMon, killMon = GetCommonBossMonsterNum6( fubenHandle, fubenCfg.monsters )
	--print("OnCommonQuestFubenMonsterKilled, allBoss="..allBoss..", killBoss="..killBoss..", allMon="..allMon..", killMon="..killMon)
	if killBoss + killMon >= allBoss + allMon then
		--LocalDT.ScriptDelayConfig中配置的延迟消息
		if FuBen[fubenId].quitCountDownTime and FuBen[fubenId].quitCountDownTime > 0 then
			Actor.postEntityScriptDelayMsg(Killer, FuBen[fubenId].quitCountDownTime*1000, 0, 16,0,0,0,0,false)
			local boardStr = Lang.ScriptTips.COM0054				--注意：字符串中要带有一个 %d
			OpenBoardPanel( Killer, enBoardPanelStyle_CountDown1, boardStr, FuBen[fubenId].quitCountDownTime )
		end

		if FuBen[fubenId].teleport and FuBen[fubenId].teleport.passVisible then
			local hScene = Actor.getSceneHandle(Killer)
			System.setTeleportVisible( true, hScene, FuBen[fubenId].teleport.posx, FuBen[fubenId].teleport.posy )
		end
	end
end

